package org.wang.web.servlet;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.wang.web.service.MyService;

public class MyServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7345046636794537186L;
	
	private MyService service;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println("Servlet Name:"+this.getClass().hashCode());
		System.out.println("Servlet Get");
		ServletContext s = this.getServletContext();
		String path = s.getInitParameter("contextConfigLocation");
		System.out.println("path:"+path);
		System.out.println("getName:"+service.getName());
		super.doGet(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println("Servlet Post");
		super.doPost(req, resp);
	}

	@Override
	public void destroy() {
		System.out.println("Servlet destory");
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		System.out.println("第一步:Servlet进行初始化");
		super.init();
	}

	public MyService getService() {
		return service;
	}

	public void setService(MyService service) {
		this.service = service;
	}
	
}
